package com.light.applet.account.controller;

import com.light.applet.account.service.AccountService;
import com.light.applet.common.entity.Account;
import com.light.applet.common.utils.UserUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 魏彪
 */
@Slf4j
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    /**
     * 当前登录用户
     */
    @GetMapping("/current")
    public Object getLoginUser() {
        return UserUtils.currentUser();
    }

    @PostMapping("/register")
    public Account register(@RequestBody Account account) {
        return accountService.register(account);
    }

    @GetMapping("/all")
    public List<Account> all() {
        return accountService.list();
    }

}
